<template>
  <div>
    <el-drawer
      :title="editConfig.title"
      :visible.sync="editConfig.deviceDrawer"
      direction="rtl"
      :before-close="handleClose">
      <!-- 人员信息 -->
      <el-form ref="form" v-if="editConfig.typeInfo==='user'" :model="editConfig.infomation.user" label-position="right" label-width="80px" size="mini">
        <el-row>
          <el-col :span="24" style="display:flex;justify-content: center;">
            <el-image
              style="width: 100px; 
              height: 100px"
              :src=" editConfig.infomation.user.personPicUrl"
              fit="fill">
            </el-image>
          </el-col>
          <el-col :span="24">
            <el-form-item label="ID" prop="tableName">
              <el-input v-model="editConfig.infomation.user.id" style="width:90%" :disabled="isDisabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="照片标识" prop="name">
              <el-input v-model="editConfig.infomation.user.picDesc" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="姓名" prop="tableName">
              <el-input v-model="editConfig.infomation.user.personName" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="性别" prop="sex">
              <el-radio v-model="editConfig.infomation.user.sex" label="1">男</el-radio>
              <el-radio v-model="editConfig.infomation.user.sex" label="2">女</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="身份证号" prop="tableName">
              <el-input v-model="editConfig.infomation.user.idCard" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="手机号" prop="tableName">
              <el-input v-model="editConfig.infomation.user.phoneNum" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人员等级" prop="monitorLevel">
              <el-select v-model="editConfig.infomation.user.monitorLevel" placeholder="请选择类型" style="width:90%">
                <el-option v-for="item in libraryOptions" :key="item.key" :label="item.leval"
                  :value="item.leval">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="入库位置" prop="tableName">
              <el-input v-model="editConfig.infomation.user.fromServerId" style="width:90%"  :disabled="isDisabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="入库时间" prop="tableName">
              <el-date-picker
                v-model="editConfig.infomation.user.createTime"
                type="datetime"
                placeholder="选择日期时间"
                :disabled="isDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="其他" prop="tableName">
              <el-input v-model="editConfig.infomation.user.reserved" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="formButton">
          <el-button @click="cancelAddLibrary">取消</el-button>
          <el-button @click="addBaseClick">保存</el-button>
        </div>
      </el-form>
      <!-- 车辆信息 -->
      <el-form ref="form" v-if="editConfig.typeInfo==='car'" :model="editConfig.infomation.car" label-position="right" label-width="80px" size="mini">
        <el-row>
          <el-col :span="24" style="display:flex;flex-direction: column;">
            <p style="margin-left: 10px;">上传车辆照片：</p>
            <el-upload
              style="margin-left: 10px;"
              :data="uploadData"
              action="/data/api-v/dbperson/fileupload"
              list-type="picture-card"
              :file-list="fileCarList"
              :on-success="onSuccessCars"
              :on-remove="handleRemoveCars">
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-col>
          <el-col :span="24" style="display:flex;flex-direction: column;margin-top:20px;">
            <p style="margin-left: 10px;">上传车主照片：</p>
            <el-upload
              style="margin-left: 10px;margin-bottom: 20px;"
              class="avatar-uploader"
              :data="uploadDataUser"
              action="/data/api-v/dbperson/fileupload"
              :show-file-list="false"
              :on-success="handleAvatarSuccessUser"
              :before-upload="beforeAvatarUploadUser">
              <img v-if="imageUrlUser" :src="imageUrlUser" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车牌号" prop="tableName">
              <el-input v-model="editConfig.infomation.car.carNo" style="width:90%" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车辆类型" prop="name">
              <el-select v-model="editConfig.infomation.car.carType" placeholder="请选择车辆类型" style="width:90%">
                <el-option v-for="item in jsonDatas.nVehicleType" :key="item.value" :label="item.name"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车辆品牌" prop="tableName">
              <el-select v-model="editConfig.infomation.car.carBrand" placeholder="请选择车辆品牌" style="width:90%">
                <el-option v-for="item in jsonDatas.nVehicleBrand" :key="item.value" :label="item.name"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车身颜色" prop="tableName">
              <el-select v-model="editConfig.infomation.car.carColor" placeholder="请选择车身颜色" style="width:90%">
                <el-option v-for="item in jsonDatas.nVehicleColor" :key="item.value" :label="item.name"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车主姓名" prop="tableName">
              <el-input v-model="editConfig.infomation.car.personName" style="width:90%" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车主性别" prop="sex">
              <el-radio v-model="editConfig.infomation.car.sex" label="男">男</el-radio>
              <el-radio v-model="editConfig.infomation.car.sex" label="女">女</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="身份证号" prop="tableName">
              <el-input v-model="editConfig.infomation.car.idCard" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="手机号" prop="tableName">
              <el-input v-model="editConfig.infomation.car.phoneNum" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="其他" prop="tableName">
              <el-input v-model="editConfig.infomation.car.reserved" style="width:90%"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="formButton">
          <el-button @click="cancelAddLibrary">取消</el-button>
          <el-button @click="addBaseClick">保存</el-button>
        </div>
      </el-form>


    </el-drawer>
  </div>
</template>

<script>
import {
  updateBaseCar,
  addDbPerson,
  // getPersonList
  // dicByType
} from "@/api/baseLibrary/baseLibrary"
// import TimeWeather from "@/views/panoramicData/components/TimeWeather.vue";
export default {
  props: {
    editConfigForm:{
      type: Object,
      default: () => {
        return {
          typeInfo:'user',
          deviceDrawer: true,
          title: "修改信息",
          infomation: {}
        }
      }
    }
  },
  data() {
    return {
      editConfig:this.editConfigForm,
      deviceDrawer:true,
      libraryOptions:[
        {
          leval:"一级",
          key:1
        },
        {
          leval:"二级",
          key:2
        },
        {
          leval:"三级",
          key:3
        },
      ],
      isDisabled:true,
      imageUrlUser:"",
      jsonDatas:JSON.parse(JSON.stringify({
        "nVehicleBrand": [
            {
                "description": "未知",
                "id": "fc28e631-23c6-4cd2-b0ea-ab68bf2df277",
                "name": "未知",
                "parent_id": "0",
                "sort": 1,
                "type": "nVehicleBrand",
                "value": "0"
            },
            {
                "description": "吉普",
                "id": "2f8d96d5-13ec-439f-94a0-3e8d9b6b38f8",
                "name": "吉普",
                "parent_id": "0",
                "sort": 2,
                "type": "nVehicleBrand",
                "value": "1"
            },
            {
                "description": "奔驰",
                "id": "d618720e-caf5-490b-8359-ef17eeb3c445",
                "name": "奔驰",
                "parent_id": "0",
                "sort": 3,
                "type": "nVehicleBrand",
                "value": "2"
            },
            {
                "description": "宝马",
                "id": "3471834b-f81c-41cb-9694-811f6ff8e19f",
                "name": "宝马",
                "parent_id": "0",
                "sort": 4,
                "type": "nVehicleBrand",
                "value": "3"
            },
            {
                "description": "奥迪",
                "id": "eb2d6596-f1c5-426b-b0c3-e5ee8e46737a",
                "name": "奥迪",
                "parent_id": "0",
                "sort": 5,
                "type": "nVehicleBrand",
                "value": "4"
            },
            {
                "description": "大众",
                "id": "0ffc24fb-1de6-4b89-acc3-2a3b90fa2be8",
                "name": "大众",
                "parent_id": "0",
                "sort": 6,
                "type": "nVehicleBrand",
                "value": "5"
            },
            {
                "description": "通用",
                "id": "37eee0b4-8f24-4cf9-b10b-ec665db7d024",
                "name": "通用",
                "parent_id": "0",
                "sort": 7,
                "type": "nVehicleBrand",
                "value": "6"
            },
            {
                "description": "福特",
                "id": "8d66a7b5-43b7-4bdb-9752-28b178ecbf0c",
                "name": "福特",
                "parent_id": "0",
                "sort": 8,
                "type": "nVehicleBrand",
                "value": "7"
            },
            {
                "description": "克莱斯勒",
                "id": "9a242898-6fd1-47d5-9e3a-563a412920a6",
                "name": "克莱斯勒",
                "parent_id": "0",
                "sort": 9,
                "type": "nVehicleBrand",
                "value": "8"
            },
            {
                "description": "比亚迪",
                "id": "6741742a-cb9f-4ee9-bc3e-4a4ae8caa9fa",
                "name": "比亚迪",
                "parent_id": "0",
                "sort": 10,
                "type": "nVehicleBrand",
                "value": "9"
            },
            {
                "description": "奇瑞",
                "id": "725fcb47-5150-4e8d-ae20-9f20124d0224",
                "name": "奇瑞",
                "parent_id": "0",
                "sort": 11,
                "type": "nVehicleBrand",
                "value": "10"
            },
            {
                "description": "吉利",
                "id": "7645aa3a-e5b1-4ce8-b7ea-cdc78232c282",
                "name": "吉利",
                "parent_id": "0",
                "sort": 12,
                "type": "nVehicleBrand",
                "value": "11"
            },
            {
                "description": "长城",
                "id": "4178a12e-be48-4bee-a840-48799a4def39",
                "name": "长城",
                "parent_id": "0",
                "sort": 13,
                "type": "nVehicleBrand",
                "value": "12"
            },
            {
                "description": "红旗",
                "id": "17c38072-c31b-47ee-a99b-b02f09ec727f",
                "name": "红旗",
                "parent_id": "0",
                "sort": 14,
                "type": "nVehicleBrand",
                "value": "13"
            },
            {
                "description": "江淮",
                "id": "8878ffdb-af53-42cc-8892-42a34af532a0",
                "name": "江淮",
                "parent_id": "0",
                "sort": 15,
                "type": "nVehicleBrand",
                "value": "14"
            },
            {
                "description": "一汽",
                "id": "a5945122-53dc-4805-8139-b84c83ec99d1",
                "name": "一汽",
                "parent_id": "0",
                "sort": 16,
                "type": "nVehicleBrand",
                "value": "15"
            },
            {
                "description": "本田",
                "id": "05acfe72-ab9f-4d46-ac31-6a6446783130",
                "name": "本田",
                "parent_id": "0",
                "sort": 17,
                "type": "nVehicleBrand",
                "value": "16"
            },
            {
                "description": "丰田",
                "id": "fff61bed-73a6-4214-b44f-a0040efa7ed7",
                "name": "丰田",
                "parent_id": "0",
                "sort": 18,
                "type": "nVehicleBrand",
                "value": "17"
            },
            {
                "description": "日产",
                "id": "4cd06a99-84ee-4d10-98e6-0ff5211a4cb6",
                "name": "日产",
                "parent_id": "0",
                "sort": 19,
                "type": "nVehicleBrand",
                "value": "18"
            },
            {
                "description": "三菱",
                "id": "97ca4ba2-bd68-410c-8e58-f5a98fce98d3",
                "name": "三菱",
                "parent_id": "0",
                "sort": 20,
                "type": "nVehicleBrand",
                "value": "19"
            },
            {
                "description": "铃木",
                "id": "f2364ecd-74d6-43d4-9124-2249f1032e81",
                "name": "铃木",
                "parent_id": "0",
                "sort": 21,
                "type": "nVehicleBrand",
                "value": "20"
            },
            {
                "description": "马自达",
                "id": "a3e06025-b11f-4724-b902-d69abcea77ed",
                "name": "马自达",
                "parent_id": "0",
                "sort": 22,
                "type": "nVehicleBrand",
                "value": "21"
            }
        ],
        "nVehicleColor": [
            {
                "description": "未知",
                "id": "f69fab66-2b90-43b5-a1b2-168ae9ebed09",
                "name": "未知",
                "parent_id": "0",
                "sort": 1,
                "type": "nVehicleColor",
                "value": "0"
            },
            {
                "description": "黑色",
                "id": "ad71764e-7d11-4f55-9f39-f253632353e6",
                "name": "黑色",
                "parent_id": "0",
                "sort": 2,
                "type": "nVehicleColor",
                "value": "1"
            },
            {
                "description": "白色",
                "id": "64fb11e5-7fd5-4e99-bcde-28a7e5267271",
                "name": "白色",
                "parent_id": "0",
                "sort": 3,
                "type": "nVehicleColor",
                "value": "2"
            },
            {
                "description": "灰色(银色)",
                "id": "e4ccb29d-5382-4249-83e7-56c21a31b484",
                "name": "灰色(银色)",
                "parent_id": "0",
                "sort": 4,
                "type": "nVehicleColor",
                "value": "3"
            },
            {
                "description": "红色",
                "id": "b37b9974-c51f-4333-bd65-b7c411f7e231",
                "name": "红色",
                "parent_id": "0",
                "sort": 5,
                "type": "nVehicleColor",
                "value": "4"
            },
            {
                "description": "蓝色",
                "id": "fdb9783e-3df2-4146-9656-972bf95221b9",
                "name": "蓝色",
                "parent_id": "0",
                "sort": 6,
                "type": "nVehicleColor",
                "value": "5"
            },
            {
                "description": "黄色",
                "id": "038ab226-4ac5-4825-b2bf-2dddc04bad29",
                "name": "黄色",
                "parent_id": "0",
                "sort": 7,
                "type": "nVehicleColor",
                "value": "6"
            },
            {
                "description": "橙色",
                "id": "8e2eadf7-47e0-4997-9661-2efc29e55f1a",
                "name": "橙色",
                "parent_id": "0",
                "sort": 8,
                "type": "nVehicleColor",
                "value": "7"
            },
            {
                "description": "棕色",
                "id": "a6e8eb97-64b9-46d9-a363-f461d62d93c6",
                "name": "棕色",
                "parent_id": "0",
                "sort": 9,
                "type": "nVehicleColor",
                "value": "8"
            },
            {
                "description": "绿色",
                "id": "bb8e2b10-f912-4996-bb2f-33196ecd0ac9",
                "name": "绿色",
                "parent_id": "0",
                "sort": 10,
                "type": "nVehicleColor",
                "value": "9"
            },
            {
                "description": "紫色",
                "id": "9ad30f42-dafe-40da-bf1e-935674465a08",
                "name": "紫色",
                "parent_id": "0",
                "sort": 11,
                "type": "nVehicleColor",
                "value": "10"
            },
            {
                "description": "青色",
                "id": "093c8eb4-78b3-4eee-8980-feca6fa093e9",
                "name": "青色",
                "parent_id": "0",
                "sort": 12,
                "type": "nVehicleColor",
                "value": "11"
            },
            {
                "description": "粉色",
                "id": "ddd5c36b-c451-47f2-9798-fb5e4504db83",
                "name": "粉色",
                "parent_id": "0",
                "sort": 13,
                "type": "nVehicleColor",
                "value": "12"
            }
        ],
        "nVehicleType": [
            {
                "description": "未知",
                "id": "1bf556a8-9c88-4b76-92f3-d86263417ea0",
                "name": "未知",
                "parent_id": "0",
                "sort": 1,
                "type": "nVehicleType",
                "value": "0"
            },
            {
                "description": "轿车",
                "id": "77edea14-2831-4c85-a0d0-1d6a0860079c",
                "name": "轿车",
                "parent_id": "0",
                "sort": 2,
                "type": "nVehicleType",
                "value": "1"
            },
            {
                "description": "货车",
                "id": "cdb6d99c-42d8-4432-a6a7-1dee3eb3b360",
                "name": "货车",
                "parent_id": "0",
                "sort": 3,
                "type": "nVehicleType",
                "value": "2"
            },
            {
                "description": "客车",
                "id": "e58ba309-a1a2-46ea-9827-6d30310566b5",
                "name": "客车",
                "parent_id": "0",
                "sort": 4,
                "type": "nVehicleType",
                "value": "3"
            },
            {
                "description": "面包车",
                "id": "51aa1f8d-d220-4f39-8b35-fd59fa55beda",
                "name": "面包车",
                "parent_id": "0",
                "sort": 5,
                "type": "nVehicleType",
                "value": "4"
            }
        ]
      })),
      carList:[],
      carUrls:[],
      faceUrl:[],
      faceFeature:'',
      fileCarList:[], 
    };
  },
  computed: {
    uploadData() {
      return {
        picType: 0
      }
    },
    uploadDataUser(){
      return {
        picType:1
      }
    }

  },
  created() {
    if(this.editConfig.typeInfo==="car"){
      this.fileCarList=[{
        url:'http:'+this.getApsPage()+this.editConfig.infomation.car.carPicUrls
      }]
      this.imageUrlUser='http:'+this.getApsPage()+this.editConfig.infomation.car.personPicUrl
      if(this.editConfig.infomation.car.carDialogType==="编辑"){
        this.carList.push(this.editConfig.infomation.car.carPicUrls)
        // 暂时是单个车辆图片，后续回显多个需要遍历
        this.carUrls.push({
          url: this.editConfig.infomation.car.carPicUrls,
          uid: this.generateUID(),
          status: "success",
        })
        //单个人员
        this.faceUrl.push({
          // url: this.editConfig.infomation.car.personPicUrl,
          url:"/httpImage/192.168.20.223:6700/76,845cfeeeb4d2?collection=persistent",
          uid: this.generateUID(),
          status: "success"
        })
      }
      // else if(this.editConfig.infomation.car.carDialogType==="新增"){
      //   this.carList=[]
      // }
    }else if(this.editConfig.typeInfo==="user"){
      console.log("-")
    }
    // if(this.editConfig.infomation.car.carDialogType==="新增"){
    //   this.fileCarList=[]
    //   this.imageUrlUser=""
    // }
    // this.dicByType()
  },
  mounted() {

  },
  watch: {

  },
  methods: {
    handleClose(done) {
      // this.$confirm('确认关闭？')
      //   .then(_ => {
          done();
      //   })
      //   .catch(_ => {});
    },
    cancelAddLibrary(){
      console.log("取消")
    },
    // 编辑人员信息
    updateBaseCar(params){
      updateBaseCar(params).then((res)=>{
        if(res.success){
          this.editConfig.deviceDrawer=false
          this.$message.success("编辑成功！")
          this.$parent.getPersonList({
            tableId: this.editConfig.infomation.user.libraryId,
            page: 1,
            size: 15,
            contentValue: "",
            orderType: "desc",
            orderName: "createTime",
          })
        }else{
          this.$message.error(res.msg)
        }
      })
    },
    // 获取车辆字典
    // dicByType(){
    //   dicByType().then((res)=>{
    //     console.log(res,"车辆字典")
    //   })
    // },
    //新增车辆信息
    addDbPerson(params){
      addDbPerson(params).then((res)=>{
        if(res.success){
          this.$parent.getPersonList({
            tableId: this.editConfig.infomation.car.tableId,
            page: 1,
            size: 15,
            contentValue: "",
            orderType: "desc",
            orderName: "createTime",
          })
          this.editConfig.deviceDrawer=false
          this.$message.success("创建成功")
        }else{
          this.$message.error(res.msg)
        }
      })
    },
    //删除车辆图片
    handleRemoveCars(file, fileCarList) {
      console.log(file, fileCarList,"删除");
    },
    // 上传车辆图片成功
    onSuccessCars(res,){
      console.log(res,"车辆")
      if(res.success){
        this.carList.push(res.data.picUrl)
        this.carUrls.push({
          url: "/httpImage/"+res.data.picUrl,
          // uid: this.generateUID(),
          status: "success",
        })
        this.$message.success("上传成功!")
      }
    },
    // 人像上传成功
    handleAvatarSuccessUser(res, file) {
      console.log(res,file,"人像上传成功")
      if(res.success){
        this.editConfig.infomation.car.personPicUrl=res.data.picUrl
        this.editConfig.infomation.car.faceFeature=res.data.faceFeature
        this.imageUrlUser = URL.createObjectURL(file.raw);
        this.faceUrl.push({
          url: "/httpImage/"+res.data.picUrl,
          // uid: this.generateUID(),
          status: "success"
        })
      }
    },
    // 人像上传前
    beforeAvatarUploadUser(file) {
      console.log(file,"人像上传前")
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    // 设置参数
    setParams(){
      let params={
        personPicUrl:this.editConfig.infomation.car.personPicUrl,
        carNo: this.editConfig.infomation.car.carNo,
        carType: Number(this.editConfig.infomation.car.carType),
        carBrand: Number(this.editConfig.infomation.car.carBrand),
        carColor: Number(this.editConfig.infomation.car.carColor),
        personName: this.editConfig.infomation.car.personName,
        sex: this.editConfig.infomation.car.sex,
        idCard: this.editConfig.infomation.car.idCard,
        phoneNum: this.editConfig.infomation.car.phoneNum,
        reserved: this.editConfig.infomation.car.reserved,
        carPicUrls:this.editConfig.infomation.car.carPicUrls||'',
        faceFeature:this.editConfig.infomation.car.faceFeature,
        enable:this.editConfig.infomation.car.enable?1:0,
        tableId:this.editConfig.infomation.car.tableId,
        carUrls:this.carUrls,
        faceUrl:this.faceUrl,
        picDesc:"",
        id:this.editConfig.infomation.car.id||'',
        monitorLevel: "one",
        name:"",
      }
      return params
    },
    // 保存
    addBaseClick(){
      if(this.editConfig.typeInfo==='user'){
        this.editConfig.infomation.user.personPicUrl = this.editConfig.infomation.user.personPicUrl.replace('"/httpImage/', '');  
        this.updateBaseCar({
          ...this.editConfig.infomation.user,
          personPicUrl:this.editConfig.infomation.user.personPicUrl.replace('/httpImage/', ''),
          enable:this.editConfig.infomation.user.enable?1:0,
          faceUrl: [
            {
              url:this.editConfig.infomation.user.personPicUrl,
            }
          ],
          // 下边是固定值--
          age: "",
          carBrand: 0,
          carColor: 0,
          carNo: "",
          carPicUrls: "",
          carType: 0,
          createBy: "admin", 
          isDelete: 0,
          updateTime: "2024-01-11 17:11:21",
          carUrls: [
            {
              "url": "/httpImage/"
            }
          ],
        })
      }else if(this.editConfig.typeInfo==='car'){
        if(this.editConfig.infomation.car.carDialogType==="新增"){
          let params=this.setParams()
          // params.carPicUrls=''
          this.carList.map((item)=>{
            params.carPicUrls=params.carPicUrls+item+";"
          })
          this.addDbPerson(params).then((res)=>{
            console.log(res,"看看")
          })
        }else if(this.editConfig.infomation.car.carDialogType==="编辑"){
          let params=this.setParams()
          params.personPicUrl= params.personPicUrl.replace("/httpImage/", ""); 
          params.personPicUrl= params.personPicUrl.replace(".jpeg", ""); 
          this.carList.map((item)=>{
            params.carPicUrls=params.carPicUrls+item+";"
          })

          // 编辑
          updateBaseCar({
            ...params,
            age:this.editConfig.infomation.car.age,
            createBy:this.editConfig.infomation.car.createBy,
            createTime:this.editConfig.infomation.car.createTime,
            fromServerId:this.editConfig.infomation.car.fromServerId,
            isDelete:this.editConfig.infomation.car.isDelete,
            updateTime:this.editConfig.infomation.car.isDelete||"",
          }).then((res)=>{
            if(res.success){
              this.editConfig.deviceDrawer=false
              this.$message.success("编辑成功！")
              this.$parent.getPersonList({
                tableId: this.editConfig.infomation.car.tableId,
                page: 1,
                size: 15,
                contentValue: "",
                orderType: "desc",
                orderName: "createTime",
              })
            }else{
              this.$message.error("编辑失败:"+res.msg)
            }
          })
          console.log("编辑")
        }
      }
    },
    // uid
    generateUID() {  
      let timestamp = Date.now();  
      let random = Math.floor(Math.random() * 100000);  
      let uid = timestamp + random;  
      uid = uid.toString().padStart(11, '0');  
      return uid;  
    },
    // 环境区分
    environmentType(){
      let type
      if (location.href.includes('192.168.20.119')) {
        type = 'test'
      } else if (location.href.includes('192.168') || location.href.includes('localhost')) {
        type = 'dev'
      } else {
        type = 'prod'
      }
      return type
    },
    // 端口匹配
    getApsPage (){
      // 首页部署在各个环境的端口
      const loginPathMap = {
        prod:`//${window.location.hostname}:7011`,
        test:`//192.168.20.119:9086`,
        // 配置自己本地的地址来访问车辆库图片
        dev: `//192.168.8.117:8081`
      }
      return loginPathMap[this.environmentType()]
    }
  },
  components: {

  },
};
</script>

<style scoped lang="scss">
::v-deep {
  .el-drawer__header{
    background-color: #1F2935 !important;
    span, i{
      color:#fff !important;
    }
    span{
      text-align:center;
    }
  }
  .el-drawer__title{
    background-color: #1F2935 !important;
  }
  .el-drawer__body{
    background-color: #1F2935 !important;
  }
  .el-drawer{
    background-color: #1F2935 !important;
    color:#fff !important;
  }
  .formButton {
    width: 100%;
    display: flex;
    margin-top: 50px;
    align-items: center;
    justify-content: center;

    .el-button {
      width: 150px;
      border-radius: 18px;
    }

    .el-button:nth-of-type(2) {
      background: rgb(78, 148, 255);
      border: rgb(78, 148, 255);
      color: #000;
    }
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
} 
</style>
